<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script type="text/javascript" src="resource/jquery/jquery-1.8.2.js"></script>
    <link rel="stylesheet" type="text/css" href="resource/css/student_input.css" />
   	<script type="text/javascript">
   	if(${session.CURRENT_USER.type==4}) {
   		$(document).ready(function(){
   			var v = $("#department").val();
   			var url = "clasz_listByDepartmentId?id=" + v;
   			if (window.XMLHttpRequest) {
   				request = new XMLHttpRequest();
   			} else if (window.ActiveXObject) {
   				request = new ActiveXObject("Microsoft.XMLHTTP");
   			}
   			request.open("GET", url, false);
   			request.onreadystatechange = callback;
   			request.send(null);
   		});
   	}
   		function findClass(obj) {
   			var v = obj.value;
   			var url = "clasz_listByDepartmentId?id=" + v;
   			if (window.XMLHttpRequest) {
   				request = new XMLHttpRequest();
   			} else if (window.ActiveXObject) {
   				request = new ActiveXObject("Microsoft.XMLHTTP");
   			}
   			request.open("GET", url, false);
   			request.onreadystatechange = callback;
   			request.send(null);
   		}
   		function callback() {
   			if (request.readyState == 4) {
   				if (request.status == 200) {
   					var datas = request.responseXML.getElementsByTagName("datas")[0].childNodes[0].nodeValue;
   					var json = eval(datas);
   					$("#clasz").empty();
   					$("#clasz").attr("disabled","disabled");
   					$("#classLeader").removeAttr("checked");
   					for(var i=0; i<json.length; i++) {
   	   					$("#clasz").append("<option value='"+json[i].id+"'>"+json[i].name+"</option>");
   					}
   				}
   			}
   		}
   		function change(o) {
   			if(o.checked==true) {
   				$("#clasz").removeAttr("disabled");
   				$("#classLeader").attr("checked",true);
   			}else {
   				$("#classLeader").removeAttr("checked");
   				$("#clasz").attr("disabled","disabled");
   			}
   		}
   		
   		function showPhoto(path){
   			$(document.getElementById('path')).attr('value',path);
   			document.getElementById("teacherPhoto").src="image_preview?path="+encodeURI(encodeURI(path));
   		}
   		
   		function openWin() {
   			open("protect/upload.jsp", "uploadpage", "width=500,height=150,left="+(screen.width-500)/2+",top="+(screen.height-150)/2+"");
   		}
   	</script>
  </head>
  <body style="font-size:18px;font-family:'微软雅黑'">
  <div style="font-size:30px;text-align:center;margin-bottom:25px">教师信息录入</div>
  <form action="teacher_add" method="post" class="form1">
  <input type="hidden" name="path" id="path"></input>
  <table width="100%" cellspacing="2" cellpadding="0" border="1" bordercolor="lightblue" height="494px">
  	<tr class="tr_height">
  		<td class="td_head">姓名：</td><td><input type="text" name="teacher.name"></td>
  		<td class="td_head">教师编号：</td><td><input type="text" name="teacher.id"></td>
  		<td rowspan="3" class="td_head">照片：</td>
  		<td rowspan="3" align="center" style="vertical-align:top;">
  				<img src="resource/image/none.jpg" alt="点击上传头像" height="140px" width="140px" onclick="openWin();" id="teacherPhoto" style="display:block"/>
  				<span style="font-size:12px;margin-top:10px;">请上传大小为140*140的图片</span>
  		</td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">学院：</td><td>
  		<select id="department" name="teacher.department.id" onchange="findClass(this)" style="width:155px">
  		<s:iterator value="departments" var="d" status="i">
  		<s:if test="teacher.department.id==#d.id">
  			<option selected="selected" value="<s:property value="#d.id"/>"><s:property value="#d.name"/></option>
  		</s:if>
  		<s:else>
  			<option value="<s:property value="#d.id"/>"><s:property value="#d.name"/></option>
  		</s:else>
  		</s:iterator>
  	</select>
	  	</td>
  		<td class="td_head"><input id="classLeader" type="checkbox" onclick="change(this);">班主任：</td><td><select id="clasz" name="classId" disabled="disabled" style="width:155px"></select></td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">职称：</td><td><select name="teacher.title.id" style="width:155px">
  			<s:if test="teacher.title.id==4">
  				<option value="1">助教</option>
  				<option value="2">讲师</option>
  				<option value="3" >副教授</option>
  				<option value="4" selected="selected">教授</option>
  			</s:if>
  			<s:elseif test="teacher.title.id==2">
  				<option value="1" >助教</option>
  				<option value="2" selected="selected">讲师</option>
  				<option value="3">副教授</option>
  				<option value="4">教授</option>
  			</s:elseif>
  			<s:elseif test="teacher.title.id==3">
  				<option value="1">助教</option>
  				<option value="2">讲师</option>
  				<option value="3" selected="selected">副教授</option>
  				<option value="4">教授</option>
  			</s:elseif>
  			<s:else>
  				<option value="1" selected="selected">助教</option>
  				<option value="2">讲师</option>
  				<option value="3">副教授</option>
  				<option value="3">教授</option>
  			</s:else>
  			</select></td>
  		<td class="td_head">身份证：</td><td><input type="text" name="teacher.personId"></td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">入职时间：</td><td><input id="empTime" type="text" name="teacher.empTime">
  	<script type="text/javascript">//<![CDATA[
      Calendar.setup({
        inputField : "empTime",
        trigger    : "empTime",
        onSelect   : function() { this.hide(); },
        showTime   : 24,
        align	   :"B",
        dateFormat : "%Y-%m-%d",
      });
    //]]></script></td>
  		<td class="td_head">出生日期：</td><td><input id="birthday" type="text" name="teacher.birthday">
  	<script type="text/javascript">//<![CDATA[
      Calendar.setup({
        inputField : "birthday",
        trigger    : "birthday",
        onSelect   : function() { this.hide(); },
        showTime   : 24,
        align	   :"B",
        dateFormat : "%Y-%m-%d",
      });
    //]]></script></td>
  		<td class="td_head">性别：</td><td><select name="teacher.sex" style="width:155px">
  			<s:if test="teacher.sex==1">
  				<option value="1">女</option>
  				<option value="0">男</option>
  			</s:if>
  			<s:else>
  				<option value="0">男</option>
  				<option value="1">女</option>
  			</s:else>
  			</select></td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">政治面貌：</td><td><select name="teacher.party" style="width:155px">
  			<s:if test="teacher.party==0">
  				<option value="0" selected="selected">群众</option>
  				<option value="1">团员</option>
  				<option value="2">党员</option>
  			</s:if>
  			<s:elseif test="teacher.party==2">
  				<option value="0">群众</option>
  				<option value="1">团员</option>
  				<option value="2" selected="selected">党员</option>
  			</s:elseif>
  			<s:else>
  				<option value="0">群众</option>
  				<option value="1" selected="selected">团员</option>
  				<option value="2">党员</option>
  			</s:else>
  			</select></td>
  		<td class="td_head">籍贯：</td><td><input type="text" name="teacher.province" ></td>
  		<td class="td_head">民族：</td><td><input type="text" name="teacher.race" ></td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">联系电话：</td><td><input type="text" name="teacher.phone"></td>
  		<td class="td_head">家庭地址：</td><td><input type="text" name="teacher.address"></td>
  		<td class="td_head">电子邮箱：</td><td><input type="text" name="teacher.email"/></td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">教龄：</td><td><input type="text" name="teacher.years"/></td>
  		<td class="td_head">学历：</td><td><input type="text" name="teacher.education"></td>
  		<td class="td_head" rowspan="2">备注：</td><td rowspan="2"><textarea style="resize:none;width:100%;height:100%;border:0;" name="teacher.remark"></textarea></td>
  	</tr>
  	<tr class="tr_height">
  		<td class="td_head">职务：</td><td><input type="text" name="teacher.duty"></td>
  		<td class="td_head">出生地：</td><td><input type="text" name="teacher.birthplace"></td>
  	</tr>
  	<tr height="30px" align="center" style="background-color:lightblue;"><td colspan="6"><input style="width:100px;height:30px;" type="submit" value="保存">
  		<input style="width:100px;height:30px;" type="reset" value="重置">
  	</td></tr>
  </table>
</form>
  </body>
</html>
